import 'package:flutter/material.dart';
import 'package:sleep/help_style.dart';
import 'package:sleep/model/blue_connection_state.dart';

class BlueItemTypeWidget extends StatelessWidget {
  final ValueChanged<BlueType> onTap;
  final BlueType? type;
  const BlueItemTypeWidget({super.key, required this.onTap, this.type});

  onClick(e) {}

  Widget myButton(BlueType blueType, bool isSelect) {
    return Expanded(
      flex: 1,
      child: Padding(
        padding: const EdgeInsets.only(left: 2.0, right: 2.0),
        child: TextButton(
            style: ButtonStyle(
              backgroundColor: MaterialStatePropertyAll(isSelect
                  ? HelpStyle.primarycolor
                  : HelpStyle.backgroundColor),
            ),
            onPressed: () {
              onTap(blueType);
            },
            child: Text(blueType.label,
                style: HelpStyle.contextStyle.copyWith(
                    color: isSelect ? Colors.white : HelpStyle.primarycolor))),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [...BlueType.values.map((e) => myButton(e, type == e))],
    );
  }
}
